<template>
  <div>
    <el-container class="main">
      <el-aside :width="tabWidth+'px'">
        <div>
          <div class="isClossTab">
          </div>
          <el-menu
            :class="'menu'"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
          >
            <el-menu-item
              :index="`${index}`"
              v-for="(item,index) in newRouters[0].children"
              :key="index"
            >
              <template slot="title">
                <router-link
                  :to="item.path" tag="div"
                >
                  <i class="el-icon-location"></i>
                  <span>{{ item.name}}</span>
                </router-link>
              </template>
            </el-menu-item>
          </el-menu>
        </div>
      </el-aside>
      <el-container>
        <el-header class="main-header">
          <span class="el-dropdown" @click="logout()">
            退出登陆
          </span>
        </el-header>
        <el-main>
          <div>
            <router-view></router-view>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { mapState } from "vuex";

export default {
  name: "home",
  data() {
   return {
      isCollapse: false,
      tabWidth: 200,
      test1: 1,
      intelval: null
    };
  },
  computed: {
    ...mapState(['newRouters'])
  },
  methods: {
    logout() {
      this.$store
        .dispatch("Logout")
          this.$router.push({ path: "/login" });
    },
  },
}
</script>

<style scoped lang="scss">
$header-height: 60px;
$background-color: #545c64;
$color: #fff;
.main {
  height: 100vh;
  min-width: 800px;
  min-height: 600px;
  overflow: hidden;

  aside {
    overflow: visible;
    height: 100%;
    background-color: $background-color;
    color: $color;

    .isClossTab {
      width: 100%;
      height: $header-height;
      cursor: pointer;
      font-size: 25px;
      text-align: center;
      line-height: $header-height;
      font-weight: bold;
      border-right: 1px solid #807c7c;
      box-sizing: border-box;
    }
    .menu {
      width: 100%;
      border-right: 0;
    }
  }
  .main-header {
    background-color: $background-color;
    color: $color;

    .el-dropdown {
      cursor: pointer;
      float: right;
      height: 100%;
      line-height: 4;
      color: #fff;
    }
  }

  .crumbs {
    margin-bottom: 20px;
  }

  .main-footer {
    text-align: center;
    background-color: $background-color;
    color: $color;
    line-height: 50px;
  }
}
</style>

